﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Doo.Scripts.Fields;

namespace Doo.Controls
{
    /// <summary>
    /// Ajax控件引用
    /// </summary>
    public class ControlReference : Field
    {
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override bool NoQuote
        {
            get
            {
                return true;
            }
        }

        /// <summary>
        /// 要查找的控件ID
        /// </summary>
        public string ControlID { get; set; }

        public override void RenderName(System.IO.TextWriter writer, System.Web.UI.Control parent)
        {
            writer.Write("get_");
            writer.Write(this.Name);
        }

        public override void RenderValue(System.IO.TextWriter writer, System.Web.UI.Control parent)
        {
            writer.Write(string.Format("function(){{return $get('{0}').control;}}", parent.FindControl(this.ControlID).ClientID));
        }
    }
}
